from django.db import models

# Create your models here.
class Cate(models.Model):
    name = models.CharField(max_length=20,verbose_name='类别名')
    cid = models.ForeignKey('self',related_name='subs',on_delete=models.CASCADE,null=True,blank=True)
    class Meta:
        db_table = 'tb_cate'
    def __str__(self):
        return self.name

class Group(models.Model):
    """分类分组"""
    name = models.CharField(verbose_name="分类分组", max_length=30)
    # 一级类别
    cate = models.OneToOneField(Cate, on_delete=models.CASCADE)
    group_url = models.CharField(verbose_name="频道的地址链接", max_length=100, default="http://jd.com")
    sequence = models.IntegerField(verbose_name="组内的顺序", default=0)
    class Meta:
        db_table = 'cate_group'
    # 不能使用group命名，会导致sql操作失败。
    def __str__(self):
        return self.name
